//
//  LTChooseContentLeftCell.m
//  LearnTeacher
//
//  Created by 高刘通 on 2024/6/7.
//

#import "LTChooseContentLeftCell.h"
#import "LTChooseContentLeftModel.h"

@interface LTChooseContentLeftCell()
@property(strong, nonatomic) UIView *lineView;
@property(strong, nonatomic) UILabel *contentLabel;
@end

@implementation LTChooseContentLeftCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self.contentView addSubview:self.lineView];
        [self.contentView addSubview:self.contentLabel];
        self.backgroundColor = [UIColor clearColor];
        self.contentView.backgroundColor = [UIColor clearColor];
        self.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    return self;
}

- (void)setModel:(LTChooseContentLeftModel *)model {
    _model = model;
    self.contentLabel.text = model.gradeName;
    if (model.lt_selected) {
        self.contentLabel.textColor = rgba(41, 121, 255, 1);
        self.lineView.backgroundColor = rgba(41, 121, 255, 1);
        self.lineView.hidden = NO;
        self.backgroundColor = [UIColor whiteColor];
        self.contentView.backgroundColor = [UIColor whiteColor];
    }else {
        self.contentLabel.textColor = rgba(51, 51, 51, 1);
        self.lineView.hidden = YES;
        self.backgroundColor = [UIColor clearColor];
        self.contentView.backgroundColor = [UIColor clearColor];
    }
}

- (void)layoutSubviews {
    [super layoutSubviews];
    self.lineView.frame = CGRectMake(0, 15, 2, self.contentView.height - 30);
    self.contentLabel.frame = CGRectMake(self.lineView.right, 0, self.contentView.width - self.lineView.right, self.contentView.height);
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (UIView *)lineView {
    if (!_lineView) {
        _lineView = [[UIView alloc] init];
    }
    return _lineView;
}

- (UIView *)contentLabel {
    if (!_contentLabel) {
        _contentLabel = [UILabel new];
        _contentLabel.textColor = rgb(90, 90, 90);
        _contentLabel.textAlignment = NSTextAlignmentCenter;
        _contentLabel.font = [UIFont systemFontOfSize:14];
    }
    return _contentLabel;
}

@end
